<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>评分标准页面</title>
<block th:replace="commonBase"></block>   
</head> 
<body>
<div style="width:100%;">
			<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
					<table style="width:100%;">
						<tr>
			                 <td style="width:100%;" > 
			                 	<a class="mini-button"  plain="true"  iconCls="icon-addnew" onclick="add">添加</a>
			                 	<a class="mini-button"  plain="true"  iconCls="icon-edit"   onclick="edit">修改</a>
			                 	<a class="mini-button"  plain="true"  iconCls="icon-remove" onclick="remove">删除</a> 
			                  </td>	
							 <td style="white-space:nowrap;">     
							    <input id="roadType" class="mini-combobox" style="width: 150px;" valueField="roadTypeCode" textField="roadTypeName" allowInput="false" showNullItem="false" onvaluechanged="search()"/>
								<input id="searchKey" class="mini-textbox" emptyText="请输入项目描述" style="width:150px;" onenter="search"/>
								<a class="mini-button"   iconCls="icon-search" onclick="search()">查询</a>    
							 </td>   
						</tr>    
					</table>
				</div>
		</div>
		<div class="mini-fit">
				<div id="grid1" class="mini-datagrid" style="width:100%;height:100%;" 
						allowCellSelect="true" multiSelect="true" allowAlternating="false" sortField="id,pid" sortOrder="asc" idField="id" pageSize="20" sizeList="[10,20,50,100]">
					<div property="columns">   
					    <div type="checkcolumn"></div>    
						<div field="id" width="100" headerAlign="center" align="left">编号</div>
						<div field="pid" width="100" headerAlign="center" align="left">父编号</div>
						<div field="projectPrefs" width="100" headerAlign="center" align="left">项目描述</div>
						<div field="inScores" width="100" headerAlign="center" align="left">分值</div>
						<div field="checkContent" width="150" headerAlign="center" align="left">检查内容</div>
						<div field="checkStand" width="150" headerAlign="center" align="left">检查标准</div>
						<div field="checkMain" width="150" headerAlign="center" align="left">评分要点</div>
					</div>    
				</div>
		</div>
</body>

<script th:inline="javascript" type="text/javascript">
 /*<![CDATA[*/

	var grid =  null;//表格对象
	$(function(){
		 mini.parse();
		 var roadTypeData = [{"roadTypeCode":"H","roadTypeName":"高速公路"},{"roadTypeCode":"P","roadTypeName":"普通公路"}];  
		 mini.get("roadType").setData(roadTypeData); 
		 mini.get("roadType").select(0); 
		 grid = mini.get("grid1");
		 search();
	});
	
	/***查询***/
	function search() {
		var roadType = mini.get("roadType").getValue();
		var url = "";
		if("H" == roadType){     //高速
			 url = basePath + "gjContenthigh/getDataGridBySearchContent";
		}else{                   //普通
			 url = basePath + "gjContentcomm/getDataGridBySearchContent";
		}
		grid.setUrl(url); 
		var searchKey= mini.get("searchKey").getValue();
		grid.load({"searchKey":searchKey});
	}
	
	function add(){         
		mini.open({
	        url:basePath+"scoringCriteria/edit",
	        title: "新增评分标准", iconCls:'icon-addnew', width: 600, height: 400,     
	        onload: function () {
	            var iframe = this.getIFrameEl();     
	            var data = { action:"new"};
	            iframe.contentWindow.setData(data);
	        },
	        ondestroy: function (action) {
				if (action != "close" && action != "cancle"){
	        		  search();
				}
	        }    
	    });
	}
	
	function edit(){
		var rows = grid.getSelecteds();
		if(rows.length>1){
			mini.alert("只能选择一条记录!");
			return;
		}
		var row = grid.getSelected();
	    if (row) {
			 mini.open({
		        url:basePath+"scoringCriteria/edit",
		        title: "修改评分标准", iconCls:'icon-edit', width: 600, height: 400,       
		        onload: function () {    
		            var iframe = this.getIFrameEl();
		            var data = {action:"edit",oneData:row,roadType:mini.get("roadType").getValue()};
		            iframe.contentWindow.setData(data);
		        },
		        ondestroy: function (action) {
					if (action != "close" && action != "cancle"){
		        		  search();
					}
		        }
		    });   
	    }
	}
	
	// 删除
	function remove(){
		var rows = grid.getSelecteds();
		if (rows.length > 0 ){
			mini.confirm("确定删除选中记录？","提示!",function(e){
			if (e == "ok"){
				var rowArray = [];// 当前删除行的数组
				for(var i = 0;i < rows.length;i++){
					var nodeFlag = rows[i].nodeFlag;
					var id = rows[i].id;
		  			if("0" == nodeFlag){
		  				showMsg("编号【"+id+"】不是叶子节点，不允许删除","warning",3000,"center","center");
		  				return;      
		  			}
					rowArray.push(id);
				}       
				
		        if (rowArray.length != 0){
		       		var ids = rowArray.toString();  
		       		 $.ajax({
		       			url:basePath+"scoringCriteria/delete",
		       			data:{"ids":ids,"roadType":mini.get("roadType").getValue()},
		       			success:function(successData){
		       	        	var message = mini.decode(successData);
				        	if(message.type == '200'){
				            	showMsg("记录删除成功","success",800,"center","center");
				        	    search();
				        	}else{
				        		showMsg("记录删除失败","warning",800,"center","center");
				        	}
		       			},
		       			error:function(errorData){
	       	 				showMsg("记录删除错误","danger",800,"center","center");
		       			}
		       		}); 
		        }
			  }
		    })    
		}else{
			mini.alert("请选中一条记录!");
		}
	}

	function ondayRenderer(e){
		var birthday = e.value;
       	if(!birthday){
       		return "";
       	}
        return format(birthday, 'yyyy-MM-dd HH:mm:ss');
	}


/*]]>*/
</script>
</html>